import http from '@/utils/http'

export interface ClassStat {
  id: string
  classId: string
  plannedStudentCount: number
  passedStudentCount: number
  renewalStudentCount: number
  cancelStudentCount: number
  retainedStudentCount: number
  totalLessonCount: number
  cancelLessonCount: number

  renewalRate: number
  fullRate: number
  cancelRate: number
  retainedRate: number
  computeDate: string
  confirmed: boolean
}

export interface ClassStatQuery {
  classYear: number | string
  term: string
}

export interface ClassStatResp extends ClassStat {
  className: string
  leadTeacherName: string
  assistTeacherName: string
  grade: string
}

export interface ClassStatSummaryResp {
  term: string
  classYear: number
  renewalRate: number
  cancelRate: number
  retainedRate: number
}

// 三率统计
export function getClassStatSummary(query: ClassStatQuery) {
  return http.get<ClassStatSummaryResp>('/t/class/stat/summary', query)
}

// 三率列表
export function getClassStatList(query: ClassStatQuery) {
  return http.get<ClassStatResp[]>('/t/class/stat/list', query)
}

// 班级三率
export function getClassStatByClassId(classId: string) {
  return http.get<ClassStat>(`/t/class/stat/class/${classId}`)
}
